package luigibros.logic.thread;

import java.awt.Graphics;
import luigibros.logic.ChangeManager;
import luigibros.logic.ScreenOccupant;
import luigibros.logic.Collidable;
import luigibros.logic.Movable;

/**
 * @author goldengrif(screenOccupant, deltaX/Y, processCollisions, move)
 * @author keilmanj(double fields, MoveThread() constructor: move.start())
 * 
 */
public class MoveThread implements Runnable, ChangeManager
{
	protected double startx;
	protected double starty;
	protected double endx;
	protected double endy;
	protected double movex;
	protected double movey;
	protected ScreenOccupant occupier;
	protected Thread move;
	
	public void MoveThread(ScreenOccupant screenocc)
	{
		this.occupier = screenocc;
		move = new Thread(this);
		move.start();
		
		
 	}
	
	public double getDeltaX()
	{
		double moveCount = 0;
		//Some method to get occupier's x starting position
		//Will be used to determine where occupier is at in the end
		double start = occupier.getX();
		
		//Some method call to get whether or not occupier is moving?
		while(occupier.moving)
		{
			moveCount++;
		}
		
		double xChange = moveCount - start;
		
		return xChange;
	}
	
	public double getDeltaY()
	{
		double heightCount = 0;
		//Some method to get occupier's y starting position
		//Will be used to determine where occupier is at in the end.
		double level = occupier.getY();
		
		//Some method to determine if occupier is still in air
		//Must stop upon landing on some object at height ?
		while (occupier.airTime)
		{
			heightCount++;
		}
		
		double yChange = heightCount - level;
		
		return yChange;
		
	}
	
	//Store start position
	//If occupant instanceof collidable, store collisions
	//if instance of movable, call move and store end position
	public void move()
	{
		startx = occupier.getX();
		starty = occupier.getY();
		
		
		
		//Need information on all occupier objects,
		//and how they move.
		//Need an actual functional enemy class, there isn't one?!
		//so I can't have an instance of an enemy
		//that isn't existant.
		if (occupier instanceof (MovableEnemy))
		{
			((Movable)(occupier)).move();
		}
			//If the instanceOf the occupier is a collidable enemy state,
			//then cast collidable and process
		else if (occupier instanceof (CollidableEnemy))
		{
			addCollissions((Collidable)occupier);
		}
	}
	
	//Some field variable to store collisions happening at the moment for this object
	//After registering DeltaX and DeltaY, process collisions
	public void addCollissions(Collidable occupant)
	{
		//Collisions for occupants aside from luigi
		//register differently, need to copy instanceof's
		//selection structure for collidables?
		//Or just make all collidables work similarly?
		//Also, different collidables for if luigi is landing on them
		//or if they are hitting him from the side? Do I deal with that here?
		
	}
	
	
	
	
}
